#pragma once
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include<boost/algorithm/string.hpp>

#include"inc/cppjieba/Jieba.hpp"
 namespace ns_util
{
   class FileUtil
   {
     public:
       static bool ReadFile(const std::string& file_path,std::string* out)
       {     
         std::ifstream in(file_path,std::ios::in);//关于这块的定义不熟悉
         //定义流之后，会自动打开文件
         if(!in.is_open())
         {
           std::cerr<<"open file"<<file_path<<"error"<<std::endl;
           return false;
         }

         std::string line;
         while(std::getline(in,line))//getline的返回值是一个ifstream的引用，为什么会成为循环结束的判断
         {                 //因为在ifstream中，有关于bool的重载，所以当没有读取到数据的时候，会发生强制类型转换，调用bool
           *out+=line;
         }
         in.close();
          return true;
       }
   };

   class StringUtil
   {
     public:
      static void Split(const std::string& line,std::vector<std::string>* out,const std::string sep)
       {
         //用boost中split函数进行切分
         boost::split(*out,line,boost::is_any_of(sep),boost::token_compress_on);
         //第四个参数的意思：是否要压缩连续出现的sep，连续出现sep，之间的内容是空，默认情况下压缩是关闭的
         
       }
   };


const char* const DICT_PATH = "./dict/jieba.dict.utf8";
const char* const HMM_PATH = "./dict/hmm_model.utf8";
const char* const USER_DICT_PATH = "./dict/user.dict.utf8";
const char* const IDF_PATH = "./dict/idf.utf8";
const char* const STOP_WORD_PATH = "./dict/stop_words.utf8";

   class JiebaUtil
   {
   static  cppjieba::Jieba jieba; 
    
   //cppjieba::Jieba jieba(DICT_PATH,HMM_PATH,USER_DICT_PATH,IDF_PATH,STOP_WORD_PATH);
     public:
    static void CutString(const std::string& src,std::vector<std::string> *out)
  {
     jieba.CutForSearch(src,*out);
  }
   };

    cppjieba::Jieba JiebaUtil::jieba(DICT_PATH,HMM_PATH,USER_DICT_PATH,IDF_PATH,STOP_WORD_PATH);

}
